package com.example.lock;

/**
 * @author csp 2020-12-21
 */
public class VolatileTest {
    private static int i = 0;
    private static boolean isStoped = false;

    public static void main(String[] args) {
            new SubThread().start();
            i = 1000;
            isStoped = true;
        }
    private static class SubThread extends Thread{
        @Override
        public void run(){
            while(!isStoped){
                System.out.println(Thread.currentThread().getName());
                Thread.yield();
            }

            System.out.println(i);
        }
    }
}
